A digital data processing system comprises three basic components: a memory, an input-output element and a processor. The manner in which the components of the computer system interact with one another and operate to process data is typically controlled through the use of an instruction set.
One type of instruction of the instruction set which is frequently used in computer systems is a procedure call instruction.
Procedures are general purpose routines which may be called by a process running on the computer system for execution in connection with the data processing operations of the processor. The procedure uses an argument list which is passed to it by the processor and further uses local variables for data storage. The procedure call instruction controls the computer system to save the contents of all of the general purpose registers of the processor which the procedure uses. The procedure call instruction also passes an argument list to the procedure. It performs other operations required to run the subroutine and preserves the desired state of the processor upon return from the procedure. The procedure terminates with a return instruction to transfer control from the procedure to the process running on the computer system which called the procedure through execution of the call procedure instruction. The return instruction restores the state of the machine and returns control to the calling program.
In one known architecture, the call instruction specifies the entry point in the memory of the procedure which is a data item, typically a word, called an entry mask. The entry mask is a sequence of bits wherein each of a certain set of the bits within the mask represents a corresponding general purpose register of the processor to be saved during the running of the procedure. If a particular bit of the entry mask is set, the contents of the corresponding general purpose register are to be saved or restored on a subroutine or procedure call using the procedure call and return instructions. Generally, the contents of a general purpose register must be saved if the called procedure will alter the contents of that general purpose register.
In one known system, the contents of the general purpose registers which are to be saved during the running of a called procedure are temporarily stored in a call frame on a memory stack. A memory stack is an area of memory set aside for temporary storage of data. The stack uses a last in/first out concept so that as data items are added to (pushed on) the stack, a stack pointer decrements and as data items are retrieved from (popped off) the stack, the stack pointer increments. The stack pointer comprises a general purpose register which contains the address of the top (lowest address) of the processor-defined stack. A call frame is a data structure built on the stack during a procedure call to store the contents of various general purpose registers identified in the entry mask. The call frame starts from a location contained in a frame pointer (a general purpose register which contains the base address of the call frame built on the stack) and expands to lower addresses. The contents of the general purpose registers identified in the entry mask are pushed on the call frame in numerical order at the beginning of a call procedure and are popped off for return to the corresponding general purpose registers upon a return from the procedure.
Upon the call of a subroutine, the entry mask is read to identify the registers that need to be saved. The accessibility of the memory space needed for storing the contents of these registers must also be determined upon reading the mask. This is done by counting the number of set bits in the entry mask to determine the total number of registers that need to be saved. Once this number is known, the total space in the memory stack required to store the state of the calling routine can be calculated. The number of set bits in the mask is used to determine, with the contents of the stack pointer register, the last location in the stack. Each general purpose register identified from the mask as a register that is to be saved, has its contents written into the memory stack.
In the prior art, the procedure for determining available memory space and for identifying registers that are to be saved is accomplished by microcode. However, the use of microcode to perform the mask data processing necessary for execution of a procedure call instruction requires excessive computer clock cycles. For example, the microcode must look at each bit of the entry mask to determine if it is set or clear and thus wastes cycles processing bit locations which are not set. This has a deleterious effect on processor performance which is not acceptable in modern high speed computer systems particularly when subroutines are used frequently. Further, there are several similar instructions, besides the procedure call and return instructions, which can use logic to reduce computer clock cycles and effectively boost performance.